/*
Copyright (c) 2010 Vadim Seregin
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/


#ifndef DBLINK_H
#define DBLINK_H

#include <wx/wx.h>
#include "wx/wxsqlite3.h"

class DbLink
{

public:
	DbLink( wxString& tutorDir, long* plCardNum );
	~DbLink();

	// get db pointers
	wxSQLite3Database* GetDictDb() { return m_pcDictDb; }
	wxSQLite3Database* GetCardDb() { return m_pcCardDb; }
	wxSQLite3ResultSet* GetWordSet() { return &m_cWordSet; }
	wxSQLite3ResultSet* GetCardSet() { return &m_cCardSet; }

	// execute SQL query
	void ExecuteQueryForCardSet( const wxString& query );
	void ExecuteQueryForWordSet( const wxString& query );

	// finalize result sets
	void FinalizeSets();

	// query new cards
	void QueryNewCards();

	// check for new sets atatus
	bool IsNewSets() { return m_bRequireNewSets; }

private:

	bool               m_bRequireNewSets;  // new sets of cards and words are required after finalization;
	long*              m_plCardNum;        // number of learning random cards
	wxSQLite3ResultSet m_cWordSet;         // query result storage
	wxSQLite3ResultSet m_cCardSet;         // query result storage
		
	wxSQLite3Database* m_pcDictDb;         // dicts databse
	wxSQLite3Database* m_pcCardDb;         // cards databse

};

#endif // DBLINK_H